
package py.una.pol.raphapy.autoventas.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Rafael E. Benegas
 */
@Entity
@Table(name = "tipo_documento")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TipoDocumento.findAll", query = "SELECT t FROM TipoDocumento t"),
    @NamedQuery(name = "TipoDocumento.findByCodTipDoc", query = "SELECT t FROM TipoDocumento t WHERE t.codTipDoc = :codTipDoc"),
    @NamedQuery(name = "TipoDocumento.findByDesTipDoc", query = "SELECT t FROM TipoDocumento t WHERE t.desTipDoc = :desTipDoc")})
public class TipoDocumento implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 4)
    @Column(name = "cod_tip_doc")
    private String codTipDoc;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "des_tip_doc")
    private String desTipDoc;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tipoDocumento")
    private Collection<DocumentoPersona> documentoPersonaCollection;

    public TipoDocumento() {
    }

    public TipoDocumento(String codTipDoc) {
        this.codTipDoc = codTipDoc;
    }

    public TipoDocumento(String codTipDoc, String desTipDoc) {
        this.codTipDoc = codTipDoc;
        this.desTipDoc = desTipDoc;
    }

    public String getCodTipDoc() {
        return codTipDoc;
    }

    public void setCodTipDoc(String codTipDoc) {
        this.codTipDoc = codTipDoc;
    }

    public String getDesTipDoc() {
        return desTipDoc;
    }

    public void setDesTipDoc(String desTipDoc) {
        this.desTipDoc = desTipDoc;
    }

    @XmlTransient
    public Collection<DocumentoPersona> getDocumentoPersonaCollection() {
        return documentoPersonaCollection;
    }

    public void setDocumentoPersonaCollection(Collection<DocumentoPersona> documentoPersonaCollection) {
        this.documentoPersonaCollection = documentoPersonaCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codTipDoc != null ? codTipDoc.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        
        if (!(object instanceof TipoDocumento)) {
            return false;
        }
        TipoDocumento other = (TipoDocumento) object;
        if ((this.codTipDoc == null && other.codTipDoc != null) || (this.codTipDoc != null && !this.codTipDoc.equals(other.codTipDoc))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.desTipDoc;
    }
    
}
